refactor(tables): migrate four list tables to useDataTableParams#1269
Conversation
|
Skipping for now — this branch currently conflicts with |
…bles-to-useDataTableParams
anderdc
left a comment
There was a problem hiding this comment.
The repository-table half is the real win — RepositoryPRsTable and RepositoryIssuesTable move sort/page onto useDataTableParams with prefixed params (prSort/prDir/prPage, issueSort/issueDir/issuePage). That's genuine URL persistence and tab isolation. Keep those, and keep the miner tables' status-filter wiring through the hook (it preserves prStatus/issueStatus byte-for-byte).
Drop the URL-backed sort on the two miner tables. In MinerPRsTable.tsx and MinerOpenDiscoveryIssuesByRepo.tsx, sort routes through the hook's bare sort/dir, but the [githubId] effect deletes sort/dir on every mount — so the URL sort never survives a mount and behaves identically to the old local sortField/sortDir, while adding transient params and an extra setSearchParams in the reset effect. Restore sort to local state on both miner tables (with the prior setPage(0) on sort change). That also avoids the miner tables writing to the same unprefixed sort/dir namespace the leaderboard tables use.
Keep:
- RepositoryPRsTable + RepositoryIssuesTable migration to useDataTableParams.
- Miner-table status-filter wiring through the hook.
Drop:
- URL-backed sort (
sort/dir) on MinerPRsTable and MinerOpenDiscoveryIssuesByRepo, including thesort/dirdeletion added to their[githubId]effects — revert those tables' sort to local state.
|
Hi @anderdc |
Summary
Migrate four list tables onto the existing
useDataTableParamshook so URL backed sort, page, and filter state share a single helper. The hook already powersTopMinersTableandTopRepositoriesTable, and these four tables were duplicating the same inline boilerplate (manualuseSearchParamsreads plususeStateforsortField/sortDir/pageplus hand rolledsetPage(0)resets on filter change).Tables migrated:
MinerPRsTable:prPageandprStatusnow flow through the hook. Sort state (previously local) is URL backed viasortanddir.MinerOpenDiscoveryIssuesByRepo: same pattern forissuePageandissueStatus.RepositoryPRsTable:prAuthormoved into the hook filters config. Sort and page state move to URL underprSort,prDir, andprPage. The session stored status filter remains a local concern.RepositoryIssuesTable: sort and page state move to URL underissueSort,issueDir, andissuePage. The session stored status filter is unchanged.All preexisting URL parameter names (
prPage,prStatus,issuePage,issueStatus,prAuthor) stay byte identical so shareable links keep working. TheDEFAULT_SORT_DIRper field overrides are preserved via the hook'sdefaultOrderOverrides, and the "reset page on filter change" semantics are preserved via the hook native page reset onsetFilterandsetSort.For the two repository tables, the new sort and page params are prefixed (
prSort/prDir/prPageandissueSort/issueDir/issuePage) so the Issues and PRs tabs on the repository details page do not stomp on each other when a user switches tabs.For the miner tables, the existing
useEffectkeyed on[githubId]still clears local UI state when navigating between miners, and now also clears the URLsortanddirparams so each miner opens with the default sort, matching prior behavior.No new dependencies. No changes to
useDataTableParams.Related Issues
N/A
Type of Change
Screenshots
No UI or visual changes in this PR, so before/after media is not applicable.
Checklist
npm run formatandnpm run lint:fixhave been runnpm run buildpasses